package com.his.controller;

import com.his.bean.DzmHisPatientFile;
import com.his.service.DzmHisPatientFileService;
import com.his.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/PatientFile")
public class DzmHisPatientFileController {
    @Autowired
    DzmHisPatientFileService dzmHisPatientFileService;

    @GetMapping("/getList")
    public ResponseResult getList(DzmHisPatientFile dzmHisPatientFile){
        List<DzmHisPatientFile> list = dzmHisPatientFileService.getList(dzmHisPatientFile);
        System.out.println(list);
        return new ResponseResult (200,"ok",list);

    }

    @PutMapping("/updateFile")
    public ResponseResult updateFile(DzmHisPatientFile dzmHisPatientFile){
        dzmHisPatientFileService.updateFile(dzmHisPatientFile);
        return new ResponseResult(200,"修改成功");
    }

    @GetMapping("/getByid/{id}")
    public ResponseResult getByid(@PathVariable Integer id){
       DzmHisPatientFile patientFile= dzmHisPatientFileService.getByid(id);

        return new ResponseResult(200,"查询对象成功",patientFile);

    }
    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteFile(@PathVariable Integer id){
        dzmHisPatientFileService.deleteFile(id);
        return new ResponseResult(200,"删除成功");
    }
    @PostMapping("/addFile")
    public ResponseResult addFile(DzmHisPatientFile dzmHisPatientFile){
        System.out.println(dzmHisPatientFile+"添加数据-----------------------------");
        dzmHisPatientFileService.add(dzmHisPatientFile);
        try {
            return  new ResponseResult(200,"添加成功");
        }catch (Exception e){
            return  new ResponseResult(500,"添加失败");
        }

    }

}
